<?php
//title
$this->headTitle($this->translate('User manage'));
//style
$this->headLink()
    ->appendStylesheet($this->STATIC_URL. '/themes/file.css')
    ->appendStylesheet($this->STATIC_URL. '/themes/page.css');
?>

<h2>
	<span><?php echo $this->translate('User manage')?></span>
	<a href="<?php echo $this->url(array(
		'action'=> 'create'
		))?>"><?php echo $this->translate('Create user')?></a>
</h2>

<dl class="zend_form">
<dt>&nbsp;</dt>
<dd>
<fieldset id="fieldset-users">
    <legend>办事处列表</legend>
	<dl class="icon_list">
		<dt style="background-image:url('<?php echo $this->STATIC_URL?>/themes/icons/user.png');">
			<h3>多用户管理</h3>
			<h5 class="leaf">为网站管理提供多用户，多权限支持，以部门化管理，分工合作，共同维护网站内容。</h5>
			<h5 class="leaf">可以为用户设置不同的权限许可，还可以指定用户可以发布内容的栏目。</h5>
		</dt>
	</dl>
    <div class="filelist">
<?php if (count($this->paginator)): ?>
<?php foreach ($this->paginator as $user): ?>
    <dl class="<?php echo $user->role?>">
        <dt><a href="<?php echo $this->url(array(
            'action'=> 'modify',
            'uid'=> $user->uid));?>">
            <?php if ($user->state) {echo '<img src="'. $this->STATIC_URL .'/themes/images/check-ok.png" />';}?></a></dt>
        <dd><?php echo $user->name ?></dd>
    </dl>
<?php endforeach;?>
<?php endif;?>
    </div>
</fieldset>
</dd>
</dl>

<form id="form_users" action="" method="get">
<dl class="zend_form">
<dt id="users-label">&nbsp;</dt>
<dd id="users-element">
	<fieldset id="fieldset-users">
		<legend>用户列表</legend>
		<dl class="icon_list">
		<dt style="background-image:url('<?php echo $this->STATIC_URL?>/themes/icons/user.png');">
			<h3>多用户管理</h3>
			<h5 class="leaf">为网站管理提供多用户，多权限支持，以部门化管理，分工合作，共同维护网站内容。</h5>
			<h5 class="leaf">可以为用户设置不同的权限许可，还可以指定用户可以发布内容的栏目。</h5>
		</dt>
<?php if (count($this->paginator)) {
foreach ($this->paginator as $user) {
	echo '<dd class="'.$user->role.'">',
		'<h3><a'. ( $user->state? ' class="check-ok"': '' ) .' href="'
			. $this->url(array(
				'action'=> 'modify',
				'uid'=> $user->uid
			)) .'" title="积分：">'. $user->name .'</a></h3>',
		'<h5 class="leaf"><span>[<em>online</em>]</span> 角色 <i>»</i> <em>'. $this->translate($user->role) .'</em></h5>',
		'<h5 class="leaf">最后登录：'. date( 'Y-m-d H:i:s', $user->login ) .'</h5>',
	'</dd>';
}}?>
		<?php echo $this->paginationControl($this->paginator, 'Sliding', array('pagination.phtml','default')); ?>
	</fieldset>
</dd>
<p>
	<select id="orderby">
		<option value="uid">用户编号</option>
		<option value="role">角色许可</option>
		<option value="state">激活状态</option>
		<option value="login">最后登录</option>
	</select>
	<input id="ASC" type="submit" value="正向排序" />
	<input id="DESC" type="submit" value="逆向排序" />
	<?php foreach (array('uid','role','state','login') as $field) {
		echo '<input type="hidden" id="'.$field.'ASC" value="'.$this->url(array('orderby'=> $field, 'orderway'=> 'ASC')).'" />';
		echo '<input type="hidden" id="'.$field.'DESC" value="'.$this->url(array('orderby'=> $field, 'orderway'=> 'DESC')).'" />';
	}?>
</p>
</dl>
</form>

<?php
//script
if ($this->request->getParam('orderby') && $this->request->getParam('orderway')) {
    $this->headScript()->appendScript('
$(function(){
    $("#'. $this->request->getParam('orderway') .'").css("color", "gray");
    $("#orderby option[value='. $this->request->getParam('orderby') .']").attr("selected", true);
});');
}
$this->headScript()->appendScript('
$(function(){
	$("#ASC").click(function(){
		$("#form_users").attr("action", $("#"+$("#orderby").val()+"ASC").val());
	});
	$("#DESC").click(function(){
		$("#form_users").attr("action", $("#"+$("#orderby").val()+"DESC").val());
	});
});');
//style
$this->headStyle('
#fieldset-users .member dt a{background-image:url("'. $this->STATIC_URL .'/themes/icons/member.png");}
#fieldset-users .editor dt a{background-image:url("'. $this->STATIC_URL .'/themes/icons/editor.png");}
#fieldset-users .master dt a{background-image:url("'. $this->STATIC_URL .'/themes/icons/master.png");}
div.filelist dl dt a {
    position:relative;
}
div.filelist dl dt img {
    position:absolute;
    right:23px;
	bottom:18px;
	background:transparent;
}
#fieldset-users dd a.check-ok {padding-left:18px;background:url("'. $this->STATIC_URL .'/themes/images/check-ok.png") no-repeat;}
');